<?PHP
date_default_timezone_set("Asia/Chongqing");
include("../public/common.php");
include("../config/connect.php");

$userid = CheckUrlParamNoDie("userid");
//$tbid = CheckUrlParamNoDie("tbid");

if ($userid != "")
{
	$sql = "select count(*) as tmp from user where commend_id='$userid'";
	$qs = mysql_query( $sql );
	$num_rows = mysql_result($qs, 0, "tmp");
	
	$sql = "SELECT count(*) as tmp1, sum(real_pay_fee) as tmp2, sum(commission) as tmp3 FROM `order_handle_report` where user_id=$userid"; 
	$qs = mysql_query( $sql );
	$row = mysql_fetch_assoc( $qs );
	
	$all_buy_count = $row["tmp1"] ? $row["tmp1"] : 0;
	$all_pay = $row["tmp2"] ? $row["tmp2"] : 0;
	$all_commission = $row["tmp3"] ? $row["tmp3"] : 0;
	
	$str = "{\"code\":1";
	$str .= ",\"user_id\":".$userid;
	$str .= ",\"all_under_users\":".$num_rows;
	$str .= ",\"all_buy_count\":".$all_buy_count;
	$str .= ",\"all_pay\":".$all_pay;
	$str .= ",\"all_commission\":".$all_commission;
	$str .= "}";
	echo $str;
}
else
	echo "{\"code\":0}";
?>